<template>
	<view>
		<view class="skill-sequence-panel-content-wrapper">
			<!--左边虚化-->
			<view class="hide-content-box hide-content-box-left"></view>
			<!--右边虚化-->
			<view class="hide-content-box hide-content-box-right"></view>
			<!-- 中间数据 -->
			<scroll-view scroll-x="true" class="kite-classify-scroll">
				<view class="screen" v-for="(item, index) in curriculum" :key="index"
					:class="{'special' : currindex== index}" @click="onclick(item,index)">
					{{ item.name }}
				</view>
			</scroll-view>
		</view>
		<view class="nav" v-for="(item,index) in list" :key="index" @click="onDetails(item)">
			<view class="left">
				<image class="logo" :src="item.acCover" mode=""></image>
				<view class="details">
					<view class="title uni-ellipsis-2">{{item.acTitle}}</view>
					<view class="lineBox">
						<view class="box" v-if="item.acTag" v-for="(val,j) in item.acTag.split(',')">
							{{val}}
						</view>
					</view>
					<view class="speciality">活动时间：{{Timeprocessing(item.acSatrt)}}-{{Timeprocessing(item.acFinish)}}
					</view>
				</view>
			</view>
			<image class="right" src="https://img.wilmer.com.cn/admin/2024/3-14/WechatIMG267.jpg" mode=""></image>
		</view>
		<image v-if="list.length == 0" class="NoData" src="https://img.wilmer.com.cn/admin/2024/3-20/WechatIMG19.jpg"
			mode=""></image>
	</view>
</template>

<script>
	import {
		activity
	} from '@/common/api/homePage.js'
	import {
		Timeprocessing
	} from '../../static/libs/util.js'
	export default {
		data() {
			return {
				curriculum: [{
						name: '全部',
						content: ''
					},
					{
						name: '培训活动',
						content: '培训活动'
					},
					{
						name: '院校活动',
						content: '院校活动'
					},
					{
						name: '主题周',
						content: '主题周'
					}
				],
				currindex: 0,
				acType: "",
				list: []
			}
		},
		onShow() {
			this.getList()
		},
		methods: {
			Timeprocessing(originalDateStr) {
				const originalDate = new Date(originalDateStr);
				const year = originalDate.getFullYear();
				const month = originalDate.getMonth() + 1; // 月份从 0 开始，所以要加 1
				const date = originalDate.getDate();
				const targetDateStr = `${year - 1}-${month < 10 ? '0' + month : month}-${date < 10 ? '0' + date : date}`;
				return targetDateStr
			},
			onclick(item, index) {
				this.currindex = index
				this.acType = item.content
				this.getList()
			},
			getList() {
				uni.showLoading({
					title: '加载中'
				});
				activity({
					acType: this.acType
				}).then(res => {
					if (res.data.code == 200) {
						this.list = res.data.rows
					}
					setTimeout(() => {
						uni.hideLoading();
					}, 500)
				})
			},
			onDetails(item) {
				uni.navigateTo({
					url: `/pages/customer/activityDetails?id=${item.acId}`
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		width: 100%;
		height: auto;
		background: #F8F8F8;
		overflow-x: hidden;
	}
</style>

<style lang="scss" scoped>
	.uni-ellipsis-2 {
		display: -webkit-box;
		overflow: hidden;
		text-overflow: ellipsis;
		word-wrap: break-word;
		white-space: normal !important;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
	}

	/*scroll-view外层*/
	.skill-sequence-panel-content-wrapper {
		position: relative;
		white-space: nowrap;
		padding: 10rpx 0 10rpx 10rpx;
	}

	/*左右渐变遮罩*/
	.hide-content-box {
		position: absolute;
		top: 0;
		height: 100%;
		width: 10px;
		z-index: 2;
	}

	.hide-content-box-left {
		left: 0;
		background-image: linear-gradient(to left, rgba(255, 255, 255, 0), #f3f3f3 60%);
	}

	.hide-content-box-right {
		right: 0;
		background-image: linear-gradient(to right, rgba(255, 255, 255, 0), #f3f3f3 60%);
	}

	.kite-classify-scroll {
		margin-top: 8px;
		width: calc(100% - 20px);
		overflow: hidden;
		white-space: nowrap;
	}

	.screen {
		display: inline-block;
		padding: 6rpx 14rpx;
		border-radius: 52rpx;
		background: linear-gradient(0deg, #D9D9D9, #D9D9D9),
			linear-gradient(0deg, #F1F2F6, #F1F2F6);
		font-family: PingFang SC;
		font-size: 14px;
		font-weight: 400;
		color: #999999;
		margin-left: 20rpx;
	}

	.special {
		color: #FFFFFF;
		background: #6CAFFF;
	}

	.nav {
		margin-top: 12rpx;
		width: 100vw;
		height: 224rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		background-color: #fff;

		.left {
			margin-left: 48rpx;
			display: flex;
			align-items: center;

			.logo {
				width: 152rpx;
				height: 152rpx;
				min-width: 152rpx;
				min-height: 152rpx;
				margin-right: 20rpx;
			}

			.details {
				display: flex;
				flex-direction: column;

				.title {
					font-family: PingFang SC;
					font-size: 28rpx;
					font-weight: 500;
					letter-spacing: 0.03em;
				}

				.lineBox {
					margin-top: 10rpx;
					display: flex;

					.box {
						font-size: 24rpx;
						font-family: PingFang SC;
						font-weight: 400;
						color: #999999;
						border-radius: 16rpx;
						padding: 4rpx 10rpx;
						background: #F1F2F6;
						margin-right: 15rpx;
					}
				}

				.speciality {
					margin-top: 10rpx;
					font-family: PingFang SC;
					font-size: 24rpx;
					font-weight: 400;
					color: #999999;

					text {
						font-family: PingFang SC;
						font-size: 28rpx;
						font-weight: 400;
						letter-spacing: 0.03em;
						color: #666666;
					}
				}
			}
		}

		.right {
			width: 24rpx;
			height: 40rpx;
			min-width: 24rpx;
			min-height: 40rpx;
			margin-right: 68rpx;
		}
	}

	.NoData {
		display: block;
		width: 400rpx;
		height: 318rpx;
		margin: 40rpx auto 0;
	}
</style>